package com.bestbuy.pojo;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.PrimaryKeyJoinColumn;
import javax.persistence.Table;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

/**
 * @author ThanhNgo
 * 
 */
@Entity
@Table(name = "account")
public class Account implements Serializable {

	@Id
	@Column(name = "IDACCOUNT")
	@GeneratedValue
	private Integer idaccount;

	@Column(name = "USERNAME")
	private String username;

	@Column(name = "PASSWORD")
	private String password;

	@Column(name = "ISDELETED")
	private Integer isdeleted;

	@ManyToOne
	@JoinColumn(name = "IDACCOUNT_ROLE")
	// @Fetch(FetchMode.JOIN)
	private AccountRole accountRole;

	@OneToOne(mappedBy = "account", cascade = CascadeType.ALL)
	private AccountInfo accountInfo;

	@OneToMany(mappedBy = "account", fetch = FetchType.LAZY)
	private Set<Comment> comments = new HashSet<Comment>(0);

	@OneToMany(mappedBy = "account", fetch = FetchType.LAZY)
	private Set<Cart> carts = new HashSet<Cart>(0);

	@OneToMany(mappedBy = "account", fetch = FetchType.LAZY)
	private Set<Bill> bills = new HashSet<Bill>(0);

	public Integer getIdaccount() {
		return idaccount;
	}

	public void setIdaccount(Integer idaccount) {
		this.idaccount = idaccount;
	}

	public AccountRole getAccountRole() {
		return accountRole;
	}

	public void setAccountRole(AccountRole accountRole) {
		this.accountRole = accountRole;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public Integer getIsdeleted() {
		return isdeleted;
	}

	public void setIsdeleted(Integer isdeleted) {
		this.isdeleted = isdeleted;
	}

	public AccountInfo getAccountInfo() {
		return accountInfo;
	}

	public void setAccountInfo(AccountInfo accountInfo) {
		this.accountInfo = accountInfo;
	}

	public Set<Comment> getComments() {
		return comments;
	}

	public void setComments(Set<Comment> comments) {
		this.comments = comments;
	}

	public Set<Cart> getCarts() {
		return carts;
	}

	public void setCarts(Set<Cart> carts) {
		this.carts = carts;
	}

	public Set<Bill> getBills() {
		return bills;
	}

	public void setBills(Set<Bill> bills) {
		this.bills = bills;
	}

	public Account() {
		// TODO Auto-generated constructor stub
	}

	public Account(Integer idaccount, AccountRole accountRole, String username,
			String password, Integer isdeleted, AccountInfo accountInfo,
			Set<Comment> comments, Set<Cart> carts, Set<Bill> bills) {
		super();
		this.idaccount = idaccount;
		this.accountRole = accountRole;
		this.username = username;
		this.password = password;
		this.isdeleted = isdeleted;
		this.accountInfo = accountInfo;
		this.comments = comments;
		this.carts = carts;
		this.bills = bills;
	}

}
